package com.sscl.baselibrary.provider

import android.annotation.SuppressLint
import android.content.ComponentName
import android.content.ContentProvider
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.net.Uri
import com.sscl.baselibrary.files.FileUtil
import com.sscl.baselibrary.utils.DebugUtil
import com.sscl.baselibrary.utils.TTsUtils

class AutoInitProvider : ContentProvider() {
    companion object {
        @SuppressLint("StaticFieldLeak")
        internal var context: Context? = null
    }
    override fun onCreate(): Boolean {
        val applicationContext = context?.applicationContext ?: return true
        TTsUtils.init(applicationContext,object : TTsUtils.OnInitListener {
            /**
             * 初始化成功
             */
            override fun initSucceed() {
                DebugUtil.warnOut("TTsUtils init succeed")
            }

            /**
             * 初始化失败
             */
            override fun initFailed() {
                DebugUtil.warnOut("TTsUtils init failed")
            }

        })
        FileUtil.init(applicationContext)
        AutoInitProvider.context = context
        return true
    }

    override fun query(
        uri: Uri,
        projection: Array<out String>?,
        selection: String?,
        selectionArgs: Array<out String>?,
        sortOrder: String?
    ): Cursor? {
        return null
    }

    override fun getType(uri: Uri): String? {
        return null
    }

    override fun insert(uri: Uri, values: ContentValues?): Uri? {
        return null
    }

    override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
        return -1
    }

    override fun update(
        uri: Uri,
        values: ContentValues?,
        selection: String?,
        selectionArgs: Array<out String>?
    ): Int {
        return -1
    }
}